﻿using SIG.Model.Store;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace SIG.Model.Mapping
{
    public class OrderMap: EntityTypeConfiguration<Order>
    {
        public OrderMap()
        {
            this.HasKey(b => b.Id);
            this.Property(b => b.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.ToTable("OrderSet");
            this.Property(p => p.Username).HasMaxLength(50).IsRequired();
            this.Property(p => p.RealName).HasMaxLength(50).IsRequired();
            this.Property(p => p.Address).HasMaxLength(250).IsRequired();
            this.Property(p => p.City).HasMaxLength(50).IsRequired();
            this.Property(p => p.State).HasMaxLength(50).IsRequired();
            this.Property(p => p.PostalCode).HasMaxLength(50).IsOptional();
            this.Property(p => p.Country).HasMaxLength(50).IsOptional();
            this.Property(p => p.City).HasMaxLength(50).IsRequired();
            this.Property(p => p.State).HasMaxLength(50).IsRequired();
            this.Property(p => p.Phone).HasMaxLength(50).IsRequired();
            this.Property(p => p.Email).HasMaxLength(50).IsOptional();
            this.Property(p => p.Total).HasPrecision(18,2).IsRequired();
            this.Property(p => p.OrderDate).IsRequired().HasColumnType("datetime");       

        }
    }
}
